package com.brp.service.impl;

import com.brp.po.Removecargo;
import com.brp.dao.RemovecargoMapper;
import com.brp.service.IRemovecargoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.brp.vo.RemoveCargoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author all
 * @since 2022-03-16
 */
@Service
public class RemovecargoServiceImpl extends ServiceImpl<RemovecargoMapper, Removecargo> implements IRemovecargoService {
    @Autowired
    private RemovecargoMapper removecargoMapper;
    @Override
    public boolean removeRemoveCargoAll() {
        return removecargoMapper.removeRemoveCargoAll() > 0 ? true: false;
    }

    @Override
    public List<RemoveCargoVo> getAllRemoveCargo() {
        List<Removecargo> allRemoveCargo = removecargoMapper.getAllRemoveCargo();
        List<RemoveCargoVo> allRemoveCargoVo = new ArrayList<>();
        for (Removecargo removecargo:allRemoveCargo) {
            RemoveCargoVo removeCargoVo = new RemoveCargoVo();
            removeCargoVo.setCargoId(removecargo.getCargo().getCargoId());
            removeCargoVo.setCargoName(removecargo.getCargo().getCargoName());
            removeCargoVo.setCargoNumber(removecargo.getCargoNumber());
            removeCargoVo.setCargoVender(removecargo.getCargo().getCargoVender());
            removeCargoVo.setCargoSalePrice(removecargo.getCargo().getCargoSalePrice());
            removeCargoVo.setCargoPurchasePrice(removecargo.getCargo().getCargoPurchasePrice());
            allRemoveCargoVo.add(removeCargoVo);
        }
        return allRemoveCargoVo;
    }
}
